﻿using DevExpress.XtraGrid.Demos.util;
using DXApplicationTangche.UC.门店出入库.Service;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace DXApplicationTangche.UC.门店出入库
{
    public partial class Form工厂向门店调拨勾稽校验 : DevExpress.XtraEditors.XtraForm
    {
        private List<StockInventoryInOutCheckDTO> stockInventoryInOutCheckDTOs = new List<StockInventoryInOutCheckDTO>();
        private String shopName { get; set; }
        public Form工厂向门店调拨勾稽校验(String shopName)
        {
            this.shopName = shopName;
            InitializeComponent();
        }

        private void dateTimePicker调拨日期_CloseUp(object sender, EventArgs e)
        {
            this.查询(this.dateTimePicker调拨日期.Value.ToString("yyyy-MM-dd"));
        }
        private void 查询(String dateStr)
        {
            if ("工厂调拨门店".Equals(this.shopName))
            {
                this.stockInventoryInOutCheckDTOs = 出入库Service.stockCheck(dateStr);
            }
            else if ("门店调拨".Equals(this.shopName))
            {
                this.stockInventoryInOutCheckDTOs = 出入库Service.shopDeliveryStockCheck(dateStr);
            }
            this.build尺寸清洗();
            this.gridControl调拨校验.DataSource = this.stockInventoryInOutCheckDTOs;
            this.advBandedGridView调拨校验.ExpandAllGroups();
            this.advBandedGridView调拨校验.RefreshData();
        }

        private void build尺寸清洗()
        {
            foreach (StockInventoryInOutCheckDTO item in this.stockInventoryInOutCheckDTOs)
            {
                if (!String.IsNullOrWhiteSpace(item.styleSizeCd))
                {
                    try { item.styleSizeCd = item.styleSizeCd.Replace("IGS_GROUP_SIZE-", "").Replace("EGS_GROUP_SIZE-", ""); } catch { }
                }
            }
        }
        private void advBandedGridView调拨校验_RowStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowStyleEventArgs e)
        {
            try
            {
                if (e.RowHandle >= 0)
                {
                    StockInventoryInOutCheckDTO checkDto = (StockInventoryInOutCheckDTO)advBandedGridView调拨校验.GetRow(e.RowHandle);
                    if (
                        String.IsNullOrWhiteSpace(checkDto.stockInTitleId)
                        || String.IsNullOrWhiteSpace(checkDto.stockInCode)
                        || String.IsNullOrWhiteSpace(checkDto.stockInStoreName)
                        || String.IsNullOrWhiteSpace(checkDto.stockInDate.ToString())
                    )
                    {
                        e.Appearance.BackColor = Color.DeepPink;
                        e.Appearance.ForeColor = Color.White;
                    }
                }
            }
            catch { }
        }
    }
}
